/**
 * 解构赋值
 */

const user = { name: "张三", age: 20 };

// 将一个对象的键值对解构，将多个值赋给多个变量
const { name, age } = user;
// const name = user.name;
// const age = user.age;
console.log(name);
console.log(age);

const arr = ["red", "green", "blue"];
const [RED, GREEN, BLUE] = arr;
// const RED = arr[0]
// const GREEN = arr[1]
// const BLUE = arr[2]
console.log(BLUE);

function f1(title = "Untitled", width = 200, height = 200) {
  console.log(`${title}:${width}:${height}`);
}
f1("hello", undefined, 400);

function f2({ title = "Untitled", width = 200, height = 200 }) {
  console.log(`${title}:${width}:${height}`);
}
f2({ width: 400 });

// let {title = "Untitled", width = 200, height = 200} = {width:400}
